
import React, { Component } from 'react';
import SonA from "./SonA";
import SonB from "./SonB";

export default class index extends Component {
  constructor(props){
    super(props);
    this.state = {
      countParent:0
    }
  }

  giveMe=(count)=>{
    this.setState({
      countParent:count
    })
  }

  render() {
    return (
      <div>
        <h1>父组件（兄弟组件传值，用状态提升）</h1>
        <hr/>
        <SonA toParent={this.giveMe} ></SonA>
        <hr/>
        <SonB count={this.state.countParent}></SonB>
      </div>
    )
  }
}
